<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>短信平台</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="all,follow">
    <!-- Bootstrap CSS-->
    <link rel="stylesheet" th:href="@{/vendor/bootstrap/css/bootstrap.min.css}">
    <!-- Font Awesome CSS-->
    <link rel="stylesheet" th:href="@{/vendor/font-awesome/css/font-awesome.css}">
    <!-- Fontastic Custom icon font-->
    <link rel="stylesheet" th:href="@{/css/fontastic.css}">
    <!-- Google fonts - Roboto -->
    <!--<link rel="stylesheet" th:href="@{https://fonts.googleapis.com/css?family=Roboto:300,400,500,700}">-->
    <!-- jQuery Circle-->
    <link rel="stylesheet" th:href="@{/css/grasp_mobile_progress_circle-1.0.0.min.css}">
    <!-- Custom Scrollbar-->
    <link rel="stylesheet" th:href="@{/vendor/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css}">
    <!-- theme stylesheet-->
    <link rel="stylesheet" th:href="@{/css/style.blue.css}" id="theme-stylesheet">
    <!-- Custom stylesheet - for your changes-->
    <link rel="stylesheet" th:href="@{/css/custom.css}">
    <!--toastr-->
    <link rel="stylesheet" th:href="@{/css/toastr.css}">
    <!-- Favicon-->
    <link rel="shortcut icon" th:href="@{/img/favicon.ico}">
    <!-- Tweaks for older IEs--><!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
    <meta name="_csrf" th:content="${_csrf.token}"/>
    <meta name="_csrf_header" th:content="${_csrf.headerName}"/>
</head>

<body>
<!-- Side Navbar -->
<div th:replace="~{/pages/common/side_navbar.html}"></div>
<div class="page">
    <!-- navbar-->
    <div th:replace="~{/pages/common/header_navbar.html}"></div>

    <!--页码代码-->
    <!-- Breadcrumb-->
    <div class="breadcrumb-holder">
        <div class="container-fluid">
            <ul class="breadcrumb">
                <li class="breadcrumb-item"><a href="#">短信管理</a></li>
                <li class="breadcrumb-item active">群组管理</li>
            </ul>
        </div>
    </div>
    <section>
        <div class="container-fluid">
            <!-- Page Header-->
            <div class="row">
                <div class="col-lg">
                    <div class="card">
                        <div class="card-header">
                            <h4>群组列表</h4>
                        </div>

                        <div class="col-lg-12">

                        </div>
                        <!--tables start -->
                        <div class="col-lg-12 grid-margin stretch-card">
                            <div class="card">
                                <div class="card-header d-flex align-items-center ">
                                    <button onclick="addGroup()" class="btn btn-success">新增</button>

                                    <button onclick="backGroupSend()" id="groupSendUrl" style="display: none"
                                            class="btn btn-secondary ml-3">
                                        返回群发短信
                                    </button>

                                </div>
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table class="table table-striped table-bordered">
                                            <thead>
                                            <td class="tc w35 text-center">序号</td>
                                            <td class="tc w150 text-center ">名称</td>
                                            <td class="tc w70 text-center ">描述</td>
                                            <td class="tc w70 text-center ">排序</td>
                                            <td class="tc w200 text-center">操作</td>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr th:each="data,loopStatus:${data.content}">
                                                <td class="tc" th:text="${loopStatus.count}"></td>
                                                <td class="tc" th:text="${data.groupName}"></td>
                                                <td class="tc" th:text="${data.groupDesc}"></td>
                                                <!--子菜单 end-->
                                                <td class="tc" th:text="${data.groupOrder}"></td>
                                                <td class="tc">
                                                    <input type="hidden" th:value="${currentPage}"
                                                           id="currentPage">
                                                    <a href="javascript:void(0)" data-toggle="modal"
                                                       data-target="#modalCenter"
                                                       th:onclick=deleteGroup([[${data.id}]],[[${data.groupName}]])
                                                       class="Cor_blue">删除</a>
                                                    <a th:href="@{/sms/group/add?id=}+${data.id}"
                                                       class="Cor_blue mr5 ml5">编辑</a>
                                                    <a href="javascript:void(0)" th:onclick="editUser([[${data.id}]])"
                                                       class="Cor_blue mr5 ml5">管理用户</a>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <div class="col-lg-6 float-none float-sm-left">
                                        <small
                                                th:text="'共'+${data.totalElements}+'条记录，每页'+${data.size}+'条,共'+${data.totalPages}+'页'"></small>
                                    </div>
                                    <div th:replace="~{/pages/common/pagination.html :: page(${data.number}+1, ${data.totalPages}, ${url}, 'currentPage') }"></div>
                                </div>
                            </div>
                        </div>
                        <!--tables end -->
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!--页码-->
    <div th:replace="~{/pages/common/foot.html}"></div>
</div>

<!-- Modal -->
<div class="modal fade" id="modalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle"
     aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalCenterTitle">删除</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body ">
                <input value="" class="del_group_id" type="hidden">
                <p class="del_message"></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary delSure" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
</body>
<!-- JavaScript files-->
<script type="text/javascript" th:src="@{/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{/vendor/popper.js/umd/popper.min.js}"></script>
<script th:src="@{/vendor/bootstrap/js/bootstrap.min.js}"></script>
<script th:src="@{/js/grasp_mobile_progress_circle-1.0.0.min.js}"></script>
<script th:src="@{/vendor/jquery.cookie/jquery.cookie.js}"></script>
<!--<script th:src="@{/vendor/chart.js/Chart.min.js}"></script>-->
<script th:src="@{/vendor/jquery-validation/jquery.validate.min.js}"></script>
<script th:src="@{/vendor/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js}"></script>
<!--<script th:src="@{/js/charts-home.js}"></script>-->
<!-- Main File-->
<script th:src="@{/js/front.js}"></script>
<script th:src="@{/js/toastr.min.js}"></script>
<script th:src="@{/js/base.js}"></script>
<script type="text/javascript">
    $(function () {
        var groupSendUrl = sessionStorage.getItem("groupSendUrl");
        if (groupSendUrl != null && groupSendUrl != "") {
            $("#groupSendUrl").attr("style", "display:block;");
            $("#groupSendUrl").val(groupSendUrl);
        }
    })
    toastr.options = {
        closeButton: false, //是否显示关闭按钮（提示框右上角关闭按钮）；
        debug: false, //是否为调试；
        progressBar: false, //是否显示进度条（设置关闭的超时时间进度条）
        positionClass: "toast-top-center", //消息框在页面显示的位置
        onclick: null, //点击消息框自定义事件
        showDuration: "300", //显示动作时间
        hideDuration: "1000", //隐藏动作时间
        timeOut: "2000", //自动关闭超时时间
        extendedTimeOut: "1000",
        showEasing: "swing",
        hideEasing: "linear",
        showMethod: "fadeIn",
        hideMethod: "fadeOut"
    };

    function deleteGroup(id, name) {
        $(".del_group_id").val(id);
        $(".del_message").text("是否确认删除菜单'" + name + "'?");
    }

    function editUser(id) {
        window.location.href = $appName + "/sms/groupUser/list?groupId=" + id + "&groupCurrentPage=" + $("#currentPage").val();
    }

    //返回群发页面
    function backGroupSend() {
        var groupSendUrl = $("#groupSendUrl").val();
        sessionStorage.setItem("menuCheckedId", "4028468173747b4001737563ee1d00b3");
        sessionStorage.setItem("hasSub", 0);
        sessionStorage.removeItem("groupSendUrl");
        //记录已发送页面
        var flag = sessionStorage.getItem("flag");
        var sendListParam = sessionStorage.getItem("sendListParam");
        window.location.href = $appName + groupSendUrl + "&flag=" + flag + "&" + sendListParam;
    }

    //跳转新增群组页面
    function addGroup() {
        window.location.href = $appName + "/sms/group/add";
    }

    //确认删除方法
    $(".delSure").click(function () {
        let id = $(".del_group_id").val();
        $.requestAjax({
                url: $appName + "/sms/group/delete",
                type: "post",
                data: {"id": id},
                success: function (result) {
                    if (result.success) {
                        toastr.success(result.msg);
                        setTimeout(function () {
                            window.location.reload();//刷新当前页面.
                        }, 1500)
                    } else {
                        toastr.error(result.msg);
                    }

                }
            }
        )
    })
</script>
</html>